'use strict';
(function (exports) {
    var $ = null;

    var ComboInfo = cc.Layer.extendEX({
        getRootNode: function () {
            return this.getChildByName('Layer');
        },

        ctor: function () {
            this._super();
            var that = this;

            var scene = ccs.load(res.PhzComboInfo_json);
            this.addChild(scene.node);

            $ = create$(this.getRootNode());

            this.imgTag = $('imgTag');
            this.txtHx = $('txtHx');

            return true;
        },
        setData: function (data, comboList) {
            this.cardSprite = [];
            var cards = data.cards;
            for (var i = 0; i < cards.length; i++) {
                var cardNo = cards[i];
                var card = new Card();
                this.addChild(card);
                card.setData(cardNo, null, 2);
                card.setPosition(30, (3 - i) * 45 + 70);
                this.cardSprite[i] = card;
            }

            var comboType = data.typ;
            if (comboType != mCard.comboTypes.dui) {
                var imgName = mCard.comboImg[comboType - 1];
                if (mRoom.wanfatype == mRoom.GUILIN &&
                    (imgName == 'wei' || imgName == 'chouwei' || imgName == 'pao' || imgName == 'ti')) {
                    imgName = imgName + '_guilin';
                    this.imgTag.setContentSize(45, 25);
                } else {
                    this.imgTag.setContentSize(28, 28);
                }
                var src = huzi.resPath+'dynamicRes/' + 'result/c_' + imgName + '.png';
                if (imgName == null) {
                    cc.log('check imgName error !');
                }
                this.imgTag.setTexture(src);
                this.imgTag.setVisible(true);
                var hx = 0;
                if (mRoom.wanfatype == mRoom.WEIMAQUE) {
                    hx = mCard.getComboHuXiWeiMaQue(data, comboList);
                } else {
                    hx = mCard.getComboHuXi(data);
                }
                this.txtHx.setString(hx);
            } else {
                this.imgTag.setVisible(false);
                this.txtHx.setString('0');
                if (mRoom.wanfatype == mRoom.WEIMAQUE) {
                    var hx = mCard.getComboHuXiWeiMaQue(data, comboList);
                    this.txtHx.setString(hx);
                }
                if (mRoom.wanfatype == mRoom.WEIMAQUE) {
                    this.imgTag.setVisible(true);
                    this.imgTag.setTexture(huzi.resPath+'dynamicRes/' + 'result/c_jiang.png');
                }
            }
            if (mRoom.wanfatype == mRoom.YOUXIAN) this.txtHx.setVisible(false);
        },
        getCardSprite: function () {
            return this.cardSprite;
        },
    });
    exports.ComboInfo = ComboInfo;
})(window);